package demo1;

import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

class BinaryTree {
    static class TreeNode {
        char val;
        TreeNode left;
        TreeNode right;
        TreeNode(char val) {
            this.val = val;
        }
    }

    static int pos = 0;
    public TreeNode CreateTree(String str) {
        if(str.charAt(pos) == '$') {
            pos++;
            return null;
        }
        TreeNode root = new TreeNode(str.charAt(pos));
        pos++;
        root.left = CreateTree(str);
        root.right = CreateTree(str);
        return root;
    }

    //中序遍历
    public void Inorder(TreeNode root) {
        if(root == null) return;
        Inorder(root.left);
        System.out.print(root.val);
        Inorder(root.right);
    }
    //后续遍历
    public void Postorder(TreeNode root) {
        if(root == null) return;
        Postorder(root.left);
        Postorder(root.right);
        System.out.print(root.val);
    }
    //层序遍历
    public void LeveOrder(TreeNode root) {
        Queue<TreeNode> queue = new LinkedList<>();
        queue.add(root);
        while(!queue.isEmpty()) {
            TreeNode peek = queue.poll();
            System.out.print(peek.val);
            if(peek.left!=null) queue.add(peek.left);
            if(peek.right!=null) queue.add(peek.right);
        }
    }

    //求深度
    public int Depth(TreeNode root) {
        if(root == null) return 0;
        if(root.left == null && root.right == null) return 1;
        return Math.max(Depth(root.left) , Depth(root.right)) + 1;
    }

    //叶子节点个数
    public int LeafNodes(TreeNode root) {
        if(root == null) return 0;
        if(root.left==null && root.right==null) return 1;
        return LeafNodes(root.left) + LeafNodes(root.right);
    }
}
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        BinaryTree tree = new BinaryTree();
        BinaryTree.TreeNode root = tree.CreateTree(str);
        int ret = tree.LeafNodes(root);
        System.out.println(ret);
    }
}
